package com.hns.its.dao;

import com.hns.its.domain.ItsSysUserLeaveEntity;
import com.hns.its.persistence.jpa.GenericRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author xy
 * @date 2017-05-25 14:15
 */
public interface IItsOrgEmployeeLeaveDao extends JpaRepository<ItsSysUserLeaveEntity, String>, JpaSpecificationExecutor<ItsSysUserLeaveEntity> {

	@Modifying
	@Query(value = "UPDATE ItsSysUserLeaveEntity set auditStatus=:auditStatus where id in (:idLst) ")
	 int updateById(@Param(value = "auditStatus") String auditStatus, @Param(value = "idLst") String[] idLst);

	@Query(value = " select count(1) from ItsSysUserLeaveEntity a where a.auditStatus= :auditStatus and a.logisticId=:logisticId")
	Long countNoaudit(@Param(value = "logisticId") String logisticId, @Param(value = "auditStatus") String auditStatus);

	@Query(value = " from ItsSysUserLeaveEntity a where a.auditStatus='APPR0002' ")
	List<ItsSysUserLeaveEntity> applyLeave();

	@Query(value = " from ItsSysUserLeaveEntity a where a.empId=:driverId")
	ItsSysUserLeaveEntity findByDriver(@Param(value = "driverId") String v);

}
